<template>
    <div>
        <slot>
            <el-button size="small" type="primary" @click="showListDialog()">
                分类列表
            </el-button>
        </slot>
        <el-dialog v-bind="dialogOpts" title="材料分类" :visible.sync="dialogVisible">
            <Table :pagination="false" v-bind="tableOpts" style="height:50vh" v-on="tableEvent">
            </Table>
        </el-dialog>
    </div>
</template>
<script>
import modifyMixins from "@/mixins/modifyMixins.vue";
import tableMixins from "@/mixins/tableMixins.vue";
import dayjs from "dayjs";
export default {
    name: 'modifyCateList',
    mixins: [modifyMixins, tableMixins],
    data() {
        return {
            apiName: "classificationClassificationList",
            dialogVisible: false,
            dialogWidth: "700px",
            form: {
                id: {
                    tag: "el-input",
                    label: "订单编号",
                    value: "",
                    props: {
                        clearable: true,
                        placeholder: "请输入订单编号",
                    },
                },
            },
        }
    },
    methods: {
        showListDialog() {
            this.dialogVisible = true;
        },
        formatData(e) {
            this.dataSource = e.rows.map(el => {
                if (el.createdAt) {
                    el.createdTime = dayjs(el.createdAt).format("YYYY-MM-DD HH:mm:ss");
                }
                return el;
            })
        },
        handleAction(opts, row) {
            const { name, classificationId } = row;
            if (opts === 'delete') {
                this.showConfirm(`确认删除【${name}】？`, "classificationClassificationDelete", {
                    classificationId,
                });
            }
        }
    }
}
</script>